package se.sll.itintegration.catalogue.offer.service;

import com.eviware.soapui.impl.wsdl.WsdlProject;
import com.eviware.soapui.model.support.PropertiesMap;
import com.eviware.soapui.model.testsuite.TestCase;
import com.eviware.soapui.model.testsuite.TestRunner;
import com.eviware.soapui.model.testsuite.TestSuite;
import com.eviware.soapui.support.SoapUIException;
import java.io.IOException;
import org.apache.xmlbeans.XmlException;
import static org.junit.Assert.assertEquals;
import org.junit.Test;

/**
 *
 * @author khaleddaham
 */
public class SoapUITest {

    WsdlProject project;

    public SoapUITest() throws XmlException, IOException, SoapUIException {
        this.project = new WsdlProject("soapui/sll-service-catalogue-offers-soapui-project.xml");
    }

    @Test
    public void testOfferService() throws Exception {
        TestSuite testSuite = project.getTestSuiteByName("Test Suite");
        TestCase testCase = testSuite.getTestCaseByName("Basic CRUD");
        // create empty properties and run synchronously
        TestRunner runner = testCase.run(new PropertiesMap(), false);
        assertEquals(TestRunner.Status.FINISHED, runner.getStatus());
    }

    @Test
    public void testFaultSuite() throws Exception {
        TestSuite testSuite = project.getTestSuiteByName("Fault Suite");
        TestCase testCase = testSuite.getTestCaseByName("Fault");
        // create empty properties and run synchronously
        TestRunner runner = testCase.run(new PropertiesMap(), false);
        assertEquals(TestRunner.Status.FINISHED, runner.getStatus());
    }
}